package app.fugema.shop.main.home.adapter;

import android.view.View;

import com.base.common.model.bean.ADInfo;
import com.base.common.view.adapter.ada.BaseRVAdapter;
import com.base.common.view.adapter.ada.SingleRecyclerAdapter;
import com.base.common.view.adapter.connector.BaseViewHolder;
import app.fugema.shop.R;
import app.fugema.shop.databinding.HomeSearchDrawerItemItemBinding;

public class HomeSearchDrawerItemAdapterMultiTypeInterface extends SingleRecyclerAdapter<ADInfo, HomeSearchDrawerItemItemBinding> {

    @Override
    public int getLayoutId() {
        return R.layout.home_search_drawer_item_item;
    }

    @Override
    public void onCreateViewHolder(HomeSearchDrawerItemItemBinding binding, BaseViewHolder viewHolder) {
        super.onCreateViewHolder(binding, viewHolder);
        binding.rtvTextView.setOnClickListener(viewHolder);
    }

    @Override
    public void onBindViewHolder(HomeSearchDrawerItemItemBinding binding, int position, ADInfo bean) {
        super.onBindViewHolder(binding, position, bean);

        if (bean.getSelected()) {
            binding.rtvTextView.getDelegate().setBackgroundColor(0xffffffff);
            binding.rtvTextView.getDelegate().setStrokeWidth(1);
            binding.rtvTextView.getDelegate().setStrokeColor(0xffFE7E11);
            binding.rtvTextView.setTextColor(0xffFE7E11);
        } else {
            binding.rtvTextView.getDelegate().setBackgroundColor(0xffF4F4F4);
            binding.rtvTextView.getDelegate().setStrokeWidth(0);
            binding.rtvTextView.setTextColor(0xff333333);
        }

    }


    @Override
    public void onItemClick(View view, BaseRVAdapter adapter, int onclickType, int position, ADInfo bean) {
        super.onItemClick(view, adapter, onclickType, position, bean);
        int pos = getSelectPosition();
        if (pos == position && bean.getSelected()) {
            setSelectPositionByUpdate(position, false);
            return;
        }

        setSelectPositionByUpdate(position, true);

    }


}
